package br.edu.univas.jobmanager.view;

import java.awt.Component;

import javax.swing.ImageIcon;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

public class TableCellRenderer extends DefaultTableCellRenderer {
	private static final long serialVersionUID = 1L;

	@SuppressWarnings("unused")
	@Override
	protected void setValue(Object value) {
		if (value instanceof ImageIcon) {
			if (value != null) {
				ImageIcon d = (ImageIcon) value;
				setIcon(d);
			} else {
				setText("Erro");
				setIcon(null);
			}
		} else {
			super.setValue(value);
		}
	}
	public Component getTableCellRendererComponent(JTable table, Object value,  
            boolean isSelected, boolean hasFocus, int row, int column) {  
		if(column==1){
			this.setHorizontalAlignment(CENTER);  
		}
        return super.getTableCellRendererComponent(table, value, isSelected,  
                hasFocus, row, column);  
    } 
}
